﻿<%@ Page Language="C#" MasterPageFile="~/Admin/admin.master" AutoEventWireup="true"
    CodeFile="ImportAdjustEdit.aspx.cs" Inherits="Admin_ImportAdjustEdit" Title="" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script src="myscript/ImportAdjustEdit.js" type="text/javascript"></script>

    <data:MultiFormView ID="FormView1" DataKeyNames="GrnId" runat="server" DataSourceID="GrnDataSource"
        OnLoad="FormView1_Load" OnItemCommand="FormView1_ItemCommand">
        <EditItemTemplatePaths>
            <data:TemplatePath Path="~/Admin/UserControls/ImportAdjustFields.ascx" />
        </EditItemTemplatePaths>
        <InsertItemTemplatePaths>
            <data:TemplatePath Path="~/Admin/UserControls/ImportAdjustFields.ascx" />
        </InsertItemTemplatePaths>
        <EmptyDataTemplate>
            <b>Grn not found!</b>
        </EmptyDataTemplate>
        <FooterTemplate>
            <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                CssClass="button" Text="Insert" ValidationGroup="Main" />
            <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                CssClass="button" Text="Update" ValidationGroup="Main" />
            <asp:Button ID="PreviewButton" runat="server" CausesValidation="True" Visible="False"
                CommandName="Preview" ToolTip="Print Preview" CssClass="button" Text="Preview"
                ValidationGroup="Main" />
            <asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                ToolTip="Return To Manage" CssClass="button" Text="Finish" ValidationGroup="Main" />
            <asp:Button ID="CloseGrn" runat="server" CausesValidation="False" Visible="false"
                CommandName="CloseGrn" ToolTip="Import Adjust To Stock" CssClass="button" Text="Import To Stock"
                OnClientClick="return confirm('After import cannot change Adjust info!');" ValidationGroup="Main" />
        </FooterTemplate>
    </data:MultiFormView>
    <asp:Panel runat="server" ID="pn_PODetailsAdd" Width="100%" Visible="false" DefaultButton="btnSave">
        <table>
            <tr>
                <td colspan="9">
                    <h3>
                        Add Import Adjust Details
                    </h3>
                </td>
            </tr>
            <tr>
                <td>
                    Drug Id:
                </td>
                <td>
                    Unit:
                </td>
                <td>
                    Cost Price:
                </td>
                <td>
                    BatchLot:
                </td>
                <td>
                    ExpDate:
                </td>
                <td>
                    Quantity:
                </td>
                <td>
                    Remark:
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <data:EntityDropDownList runat="server" ID="dataDrugId" DataSourceID=""
                        DataTextField="DrugName" DataValueField="DrugId" AppendNullItem="true" Required="true"
                        TabIndex="10" NullItemText="< Please Choose ...>" ErrorText="Required" onchange="GetDrug($(this).val());" />
                    <%--<data:DrugDispoDataSource ID="DrugIdDrugDispoDataSource" runat="server" SelectMethod="GetPaged">
                        <Parameters>
                            <data:CustomParameter Name="OrderByClause" Value="DrugName" ConvertEmptyStringToNull="false" />
                        </Parameters>
                    </data:DrugDispoDataSource>--%>
                </td>
                <td align="left">
                    <span id="UnitResult" style="color: #CC6600; font-weight: bold; min-width: 40px">
                    </span>
                </td>
                <td>
                    <span id="CostPriceResult" style="color: #808000; font-weight: bold"></span>
                </td>
                <td align="left">
                    <input type="text" runat="server" id="TxtBatchLot" class="text-input" tabindex="11"
                        value="" style="width: 80px" />
                </td>
                <td align="left">
                    <input type="text" runat="server" id="txtExpDate" class="text-input datepicker" tabindex="11"
                        value="" style="width: 80px" />
                </td>
                <td>
                    <input type="text" runat="server" id="tbQuantity" class="text-input" tabindex="11"
                        value="1" style="width: 30px" />
                </td>
                <td>
                    <input type="text" runat="server" id="tbRemark" class="large-input text-input" tabindex="12" />
                </td>
                <td>
                    <asp:Button ID="btnSave" Text="Add" class="button" TabIndex="13" runat="server" OnClick="btnSave_Click" />
                    <input type="button" id="btnCancel" value="Cancel" class="button" style="display: none"
                        tabindex="14" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <data:PoDataSource ID="PoDataSource" runat="server" SelectMethod="GetByPoId">
        <Parameters>
            <asp:QueryStringParameter Name="PoId" QueryStringField="PoId" Type="String" />
        </Parameters>
    </data:PoDataSource>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
        </Triggers>
        <ContentTemplate>
            <data:EntityGridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="GrnDetailsDataSource"
                DataKeyNames="GrnDetailId" AllowMultiColumnSorting="false" DefaultSortColumnName=""
                DefaultSortDirection="Ascending" ExcelExportFileName="Export_GrnDetails.xls"
                Visible='<%# FormView1.DefaultMode != FormViewMode.Insert %>'>
                <Columns>
                    <%-- <asp:CommandField ShowDeleteButton="true" />--%>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <a href="#<%#Eval("GrnDetailId") %>" onclick="DeleteRow(this,<%#Eval("GrnDetailId")
    %>);" style="display: <%#(Boolean)Eval("GrnIdSource.IsComplete")?"none":"inherit"
    %>">Delete</a>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <data:HyperLinkField HeaderText="Drug
    Id" DataNavigateUrlFormatString="DrugDispoEdit.aspx?DrugId={0}" DataNavigateUrlFields="DrugId" DataContainer="DrugIdSource"
                        DataTextField="DrugName" />
                    <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="[Quantity]" />
                    <asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" SortExpression="[UnitPrice]" />
                    <asp:BoundField DataField="ExpDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Exp Date"
                        SortExpression="[ExpDate]" />
                    <asp:BoundField DataField="BatchLot" HeaderText="Batch Lot" SortExpression="[BatchLot]" />
                    <asp:BoundField DataField="Remark" HeaderText="Remark" SortExpression="[Remark]" />
                </Columns>
                <EmptyDataTemplate>
                    <b>No Import Adjust Details Found!</b>
                </EmptyDataTemplate>
            </data:EntityGridView>
            <br />
            <data:GrnDetailsDataSource ID="GrnDetailsDataSource" runat="server" SelectMethod="GetPaged"
                EnablePaging="True" EnableSorting="True" EnableDeepLoad="True">
                <DeepLoadProperties Method="IncludeChildren" Recursive="False">
                    <Types>
                        <data:GrnDetailsProperty Name="DrugDispo" />
                        <data:GrnDetailsProperty Name="Grn" />
                    </Types>
                </DeepLoadProperties>
                <Parameters>
                    <data:SqlParameter Name="WhereClause" UseParameterizedFilters="false">
                        <Filters>
                            <data:GrnDetailsFilter Column="GrnId" QueryStringField="GrnId" ComparisionType="Equals" />
                        </Filters>
                    </data:SqlParameter>
                    <%--<data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false"
    /> <data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false"
    /> <asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex"
    Type="Int32" /> <asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize"
    Type="Int32" /> <data:CustomParameter Name="RecordCount" Value="0" Type="Int32"
    />--%>
                </Parameters>
            </data:GrnDetailsDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />
    <data:GrnDataSource ID="GrnDataSource" runat="server" SelectMethod="GetByGrnId">
        <Parameters>
            <asp:QueryStringParameter Name="GrnId" QueryStringField="GrnId" Type="String" />
        </Parameters>
    </data:GrnDataSource>
    <br />
    <br />
</asp:Content>
